#include <bits/stdc++.h>
using namespace std;
int T,n,m,ans,dep=1,sum;
int a[100005],b[100005];
long double L,V;
struct car{
    long double d,v,a;
}c[100005];
bool cmp(car x,car y){
    return x.d<=y.d;
}
long double p[100005];
bool over[100005];
int bfs(int i,int j){
    if(i>j) return 1;
    for(int t=i+1;t<=j;t++){
        if(b[t]>b[i]){
            return bfs(i+1,t-1)+bfs(t,j);
            break;
        }
    }
}
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        dep=1;ans=0;memset(over,0,sizeof(over));
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++) cin>>c[i].d>>c[i].v>>c[i].a;
        sort(c+1,c+n+1,cmp);
        for(int i=1;i<=m;i++) cin>>p[i];
        if(c[1].a>=0){
            for(int i=1;i<=n;i++){
                if(c[i].d<=p[m]&&sqrt(c[i].v*c[i].v+2*c[i].a*(p[m]-c[i].d))>V) ans++;
            }
            cout<<ans<<' ';
            if(!ans) cout<<m<<endl;
            else cout<<m-1<<endl;
        }
        /*
        for(int i=1;i<=n;i++){
            if(c[i].d>p[m]) over[i]=0;     
            else{
                for(int j=dep;j<=m;j++){
                    if(p[j]>=c[i].d){
                        dep=j;
                        break;
                    }
                } 
                if(c[i].a<0){
                    if(sqrt(c[i].v*c[i].v+2*c[i].a*(p[dep]-c[i].d))>V){
                        over[i]=1;
                        sum++;
                        long double x=(c[i].v*c[i].v-V*V)/(2*c[i].a*1.0);
                        for(int j=dep;j<=m;j++){
                            if(d[j]>=x) b[sum]=j,break;
                        }
                    }
                }
                else{
                    if(sqrt(c[i].v*c[i].v+2*c[i].a*(p[m]-c[i].d))>V){
                        over[i]=1;
                        sum++;
                        b[sum]=m;
                    }
                }
            cout<<ans<<endl;
        }
        */
    }
    return 0;
}